#ifndef _sbrush_sms_h_
#define _sbrush_sms_h_

#include <string>
#include "sbrush_errors.h"
#include "sms.h"
#include "dag.h"

namespace sbrush {

	class SmsError : public AcsError {
	public:
		SmsError(const std::string& msg);
		virtual ~SmsError() throw();

	};
	
	class LibSmsError : public SmsError {
	public:
		LibSmsError(int err);
		virtual ~LibSmsError() throw();
		int code() const;
	private:
		int m_Code;
	};
	
	class IncompatibleFrameSpec : public SmsError {
	public:
		IncompatibleFrameSpec();
		virtual ~IncompatibleFrameSpec() throw();
	};
	class Sms {
	public:
		Sms();
		virtual ~Sms() throw();
		static void inflateHeader(SMS_Header*& header, 
								  std::istream& binaryStream);
		static void serializeHeader(SMS_Header& header, 
									std::ostream& binaryStream);
		static void inflateData(const SMS_Header& header, 
								SMS_Data& data, 
								std::istream& binaryStream);
		static void serializeData(const SMS_Header& header, 
								  const SMS_Data& data,
								  std::ostream& binaryStream);
		static void initEmptyFrame(SMS_Data& data);
		static void copy(SMS_Data& to, const SMS_Data& from);
		static void logFrame(const SMS_Data& data);
		static void sms2Frame(const SMS_Data& data, dag::Frame& frame);
		static void frame2Sms(const dag::Frame& frame,
							  const SMS_Header& header,
							  SMS_Data& data);
		static void frame2Sms(const dag::Frame& frame,
							  SMS_Data& data);
	private:
		static int m_RefCount;
	};
}



#endif